package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbOrganizationEnter;
import com.ruoyi.wb.dto.WbOrganizationEnterDto;
import com.ruoyi.wb.service.IWbOrganizationEnterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 机构入驻
Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/wb/organization")
public class WbOrganizationEnterController extends BaseController
{
    @Autowired
    private IWbOrganizationEnterService wbOrganizationEnterService;

    /**
     * 查询机构入驻列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbOrganizationEnter wbOrganizationEnter)
    {
        startPage();
        List<WbOrganizationEnter> list = wbOrganizationEnterService.selectWbOrganizationEnterList(wbOrganizationEnter);
        return getDataTable(list);
    }

    /**
     * 导出机构入驻列表
     */
    @Log(title = "机构入驻", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbOrganizationEnter wbOrganizationEnter)
    {
        List<WbOrganizationEnter> list = wbOrganizationEnterService.selectWbOrganizationEnterList(wbOrganizationEnter);
        ExcelUtil<WbOrganizationEnter> util = new ExcelUtil<WbOrganizationEnter>(WbOrganizationEnter.class);
        util.exportExcel(response, list, "机构入驻数据");
    }

    /**
     * 获取机构入驻详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wbOrganizationEnterService.selectWbOrganizationEnterById(id));
    }

    /**
     * 新增机构入驻
     */
    @Log(title = "机构入驻", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbOrganizationEnter wbOrganizationEnter)
    {
        return toAjax(wbOrganizationEnterService.insertWbOrganizationEnter(wbOrganizationEnter));
    }

    /**
     * 修改机构入驻

     */
    @Log(title = "机构入驻", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbOrganizationEnterDto wbOrganizationEnterDto)
    {
        return toAjax(wbOrganizationEnterService.updateWbOrganizationEnter(wbOrganizationEnterDto));
    }

    /**
     * 删除机构入驻
     */
    @Log(title = "机构入驻", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wbOrganizationEnterService.deleteWbOrganizationEnterByIds(ids));
    }


    /**
     * 获取机构入驻详细信息
     */
    @GetMapping(value = "/byUser")
    public AjaxResult byUser()
    {
        return success(wbOrganizationEnterService.byUser());
    }
}
